﻿define(['certificate', 'quali', 'jquery', 'kendo'], function (certificate, quali, $, kendo) {

    var certificateType = JSON.parse(document.getElementById('certificateTypes').value);
    var treeDataSource = JSON.parse(document.getElementById('treeDataSource').value);
    var allDepartments = JSON.parse(document.getElementById('allDepartments').value);
    var model = JSON.parse(document.getElementById('model').value);

    $('#my-profile').click(function () {
        var myWindow = $("#window");
        function onClose() {
            $(this).fadeIn();
        }

        myWindow.kendoWindow({
            width: "1050px",
            title: "证件管理",
            visible: false,
            modal: true,

            actions: [
                "Minimize",
                "Maximize",
                "Close"
            ],
            close: onClose,
            open: function (e) {
                this.wrapper.css({ top: 100 });
            }
        }).data("kendoWindow").center().open();

        certificate(model.Id, '#windoGrid', certificateType);
    });
    $('#my-skill').click(function () {
        var myWindow = $("#windowQuali");

        function onClose() {
            $(this).fadeIn();
        }

        myWindow.kendoWindow({
            width: "1100px",
            title: "资质管理",
            modal: true,
            visible: false,
            actions: [
                "Minimize",
                "Maximize",
                "Close"
            ],
            close: onClose,
            open: function (e) {
                this.wrapper.css({ top: 100 });
            }
        }).data("kendoWindow").center().open();

        quali(model.Id, '#windoGrid2');
    });

    $('#saveBtn').click(function () {
        var birthday = $('#birthday').val();
        var phone = $('#phone').val();
        var sex = $('#sex').val();
        var number = $('#number').val();
        var name = $('#name').val();

        model.Name = name;
        model.Sex = sex;
        model.Number = number;
        model.Phone = phone;
        model.BirthDay = birthday;
        var models = [];
        models.push(model);
        $.ajax({
            url: '/user/save',
            method: 'post',
            //contentType: 'application/json',
            data: { users: models },
            success: function () {
                alert('保存成功');
            }
        });
    });
});